package com.beans;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
@Component
public class UserBeans {
    @Bean(name = "User1")
    public User getUser(){
        User user = new User();
        user.setId(1);
        user.setName("张三");
        return user;
    }
    @Bean(name = "User2")
    public User getUser2(){
        User user = new User();
        user.setId(2);
        user.setName("李四");
        return user;
    }
    @Bean(name = "User3")
    @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
    public User getUser3(){
        User user = new User();
        user.setId(1);
        user.setName("Java");
        return user;
    }

//    @Bean(name = "User1")
//    public User getUser(){
//        User user = new User();
//        user.setId(1);
//        user.setName("张三");
//        return user;
//    }
//    @Bean(name = "User2")
//    public User getUser2(){
//        User user = new User();
//        user.setId(2);
//        user.setName("李四");
//        return user;
//    }
}
